/*
 * @Author: zzr
 * @Date: 2025-01-16 10:49:50
 * @LastEditors: zzr
 * @Description:
 */

export const removeFindIndex = (list, id, curObj, curIndex) => {
  const index = list.value.findIndex((listItem) => listItem.id === id);
  if (index !== -1) {
    // list.value.splice(index, 1);

    // 更新 current 索引
    if (curIndex.value >= list.value.length) {
      curIndex.value = Math.max(0, list.value.length - 1);
    } else if (index <= curIndex.value) {
      curIndex.value = Math.max(0, curIndex.value - 1);
    }
  }
  if (curObj.value && id == curObj.value?.id) {
    curObj.value = null;
    curIndex.value = null;
  }
};
